﻿using System;
using System.Diagnostics.Contracts;
using System.IO;

namespace OpenLS.Spreadsheet.Formats.Biff.OfficeArt
{
    internal class OfficeArtBlipEMF : OfficeArtHeaderedBlip
    {
        public OfficeArtBlipEMF(byte[] data): base (data)
        {
            this.NativeFormat = EmfFormat.One;
        }

        public OfficeArtBlipEMF()
        {
        }

        public override RecType RecordType
        {
            get { return RecType.OfficeArtBlipEMF; }
        }


        protected override string Extension
        {
            get { return "emf"; }
        }

        protected override ushort Format
        {
            get { return (ushort) NativeFormat;   }
            set { NativeFormat = (EmfFormat) value; }
        }
        private EmfFormat _nativeFormat;

        private EmfFormat NativeFormat
        {
            get
            {
                Contract.Ensures(Enum.IsDefined(typeof(EmfFormat), Contract.Result<EmfFormat>()));
                return _nativeFormat;
            }
            set
            {
                Contract.Requires(Enum.IsDefined(typeof (EmfFormat), value));
                _nativeFormat = value;
            }
        }
        
        enum EmfFormat
        {
            One = 0x3D4,
            Two = 0x3D5,
        }
        protected override UidCount HasTwoIds()
        {
            switch(NativeFormat)
            {
                case EmfFormat.One: return UidCount.One;
                case EmfFormat.Two: return UidCount.Two;
                default:
                    throw new NotSupportedException();
            }
        }

        internal override MSOBLIPTYPE Type
        {
            get { return MSOBLIPTYPE.msoblipEMF; }
        }
    }
}